package com.untour.im.client.command;

import io.netty.channel.Channel;
import org.springframework.util.StringUtils;

import java.util.Scanner;

public class ClientActionCommand implements ActionCommand {
    private static final String login_key = "登录";
    @Override
    public void exec(Scanner scanner, Channel channel) {
        String next = scanner.next();
        if(StringUtils.hasText(next)){
            if (next.contains(login_key)) {
                String token = scanner.next();
                ClientPacketEncodec.INSTANCE.sendLoginRequestMessage(channel, token, "我要登录");
            } else {
                String toUserId = scanner.next();
                String message = scanner.next();
                ClientPacketEncodec.INSTANCE.sendSingleToUserRequestMessage(channel, toUserId, message);
            }
        }

    }
}
